package cn.wubo.vrr.help.service.impl;

import cn.wubo.vrr.help.entity.Credential;
import cn.wubo.vrr.help.repository.CredentialRepo;
import cn.wubo.vrr.help.service.CredentialService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Example;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CredentialServiceImpl implements CredentialService {
    @Autowired
    CredentialRepo credentialRepo;

    @Override
    public List<Credential> saveOrUpdateAll(List<Credential> list) {
        if(list.size() > 0){
            Credential query = new Credential();
            query.setEMPLID(list.get(0).getEMPLID());
            credentialRepo.deleteAll(credentialRepo.findAll(Example.of(query)));
            list = credentialRepo.saveAll(list);
        }
        return list;
    }
}
